<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>修改密码</title>
		<link rel="stylesheet" href="css/lib/bootstrap.min.css"/>
		<script src="js/lib/jquery-1.11.0.js"></script>
		<script src="js/lib/bootstrap.min.js"></script>
	</head>
	<style type="text/css">
		body{
			font-size:12px;
		}
		table,
		/* th,
		td {
			border: 1px solid grey;
			border-collapse: collapse;
			padding: 5px;
			vertical-align: middle !important;
		}
		 */
		table tr:nth-child(1) {
			background-color: #f1f1f1;/*#e2e9ea*/
			width:160px;
		}
		table td:nth-child(even) {
			width:300px;
		}
		table tr:nth-child(even) {
			background-color:#ffffff;
		}
		input{
			width:280px;
		}
		span{
			width:20px;color:red;display:inline-block;text-align:center;
		}
	</style>
	<body style="font-size:12px;">
		<div class="">
			<div style="padding:15px 5px 0px 5px;border:3px solid #ccc;margin-bottom:15px">
				<table class="table table-hover">
					<tbody>
						<tr>
							<th colspan="3">用户登陆密码更改：</th>
						</tr>
						<tr>
							<td style="width:80px;">
								手机号码：
							</td>
							<td colspan="2">
								<input id="m1" class="form-control" type="text"  style="width:280px;"/>
							</td>
						</tr>
						<tr>
							<td style="width:80px;">验证码：</td>
							<td>
								<input id="m2" class="form-control" type="text" style="width:280px;"/>
							</td>
							<td>
				                <input type="button" id="btn1" class="btn btn-danger" style="display:block;margin:0 auto" value="获取验证码"/>
							</td>
						</tr>
						<tr>
							<td style="width:80px;">新的登陆密码：</td>
							<td colspan="2">
								<input id="m3" class="form-control" type="text" style="width:280px;"/>
							</td>
						</tr>
						<tr>
							<td colspan="3">
								<button id="btn2" class="btn btn-danger" style="display:block;margin:0 auto">确认修改</button>
							</td>
						</tr>
					</tbody>
				</table>
			</div>
			
			<div style="padding:15px 5px 0px 5px;border:3px solid #ccc;margin-bottom:15px">
				<table class="table table-hover">
					<tbody>
						<tr>
							<th colspan="6">用户支付密码更改：</th>
						</tr>
						<tr>
							<td style="width:136px;">
								更改的支付密码：
							</td>
							<td colspan="3">
								<input id="k1" class="form-control" type="text"  style="width:280px;"/>
							</td>
						</tr>
						<tr>
							<td colspan="3">
								<button id="btn3" class="btn btn-danger" style="display:block;margin:0 auto">确认修改</button>
							</td>
						</tr>
					</tbody>
				</table>
			</div>
		</div>
	</body>
	<script>
		$(function(){
			var wait=60;			
			function time(o) {  
			        if (wait == 0) {  
			            o.removeAttribute("disabled");            
			            o.value="获取验证码";  
			            wait = 60;
			        } else {  
			            o.setAttribute("disabled", true);  
			            o.value="重新发送" + wait ;  
			            wait--;			            
			            setTimeout(function() {  
			                time(o)  
			            },  
			            1000)  
			        }  
			    };
			  /*点击获取验证码*/		
	          $("#btn1").click(function(){
	         	var bid = sessionStorage.getItem(key=3);
	         	var m1 = $('#m1').val();
	         	if(m1 == ""){
	         		alert('请输入手机号码！')
	         	}else{
	         		time(this);
	         		$.ajax({
							type:'GET',
							url:window.baseUrl+'notice/sms/send?phone='+m1+'&brand_id='+bid,
							datatype:'json',
							success:function(data){
								alert('成功')
								console.log(data)
							},
							error:function(data){
								alert('失败')
							}
						})
	         	}						
	         });
			//点击修改登陆密码
			$('#btn2').click(function(){
				var m1 = $('#m1').val();
				var m2 = $('#m2').val();
				var m3 = $('#m3').val();
				if(m1 =="" || m2 =="" || m3 ==""){
					alert('输入有误')
				}else{
					$.ajax({
					url:window.baseUrl+'user/password/update',
					datatype:'json',
					type:'POST',
					data:{
						phone:m1,
						vericode:m2,
						password:m3,
					},
					success:function(data){
						console.log(data)
						alert('修改密码成功！')
						$('#m1').val("");
				        $('#m2').val("");
				        $('#m3').val("");
					},
					error:function(data){
						console.log(data)
						alert('修改密码失败！')
						$('#m1').val("");
				        $('#m2').val("");
				        $('#m3').val("");
					}
				})
				}
			})
			/*点击更改用户支付密码*/
			$('#btn3').click(function(){
				var token = sessionStorage.getItem(key=1)
				var k1 = $('#k1').val();
				console.log(token)
	         	$.ajax({
							type:'POST',
							url:window.baseUrl+'user/paypass/update/'+token,
							datatype:'json',
							async:true,
							data:{
								paypass:k1
							},
							success:function(data){
								alert('成功')
								console.log(data)
								$('#k1').val("")
							},
							error:function(data){
								alert('失败')
							}
						})
			
		})
	})
	</script>
</html>
